package com.jzl.swing.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.jzl.swing.dao.ReportDao;
import com.jzl.swing.dao.impl.ReportDaoImpl;
import com.jzl.swing.entity.BillReport;
import com.jzl.swing.service.BillReportService;

public class BillReportServiceImpl implements BillReportService{
	ReportDao reportDao = new ReportDaoImpl();
	
	@Override
	public List<BillReport> queryAllNoReport() {
		
		List<BillReport> list = new ArrayList<BillReport>();
		list = reportDao.queryByProduct(); 
		for (int i = 0; i < list.size()-1; i++) {
			for(int j = i+1; j < list.size(); j++) {
				if (list.get(j).getBill_product_name().equals(list.get(i).getBill_product_name())) {
					double price = Double.parseDouble(list.get(j).getBill_price())+Double.parseDouble(list.get(i).getBill_price());
					int number = Integer.parseInt(list.get(j).getBill_product_number())+Integer.parseInt(list.get(i).getBill_product_number());
					list.get(i).setBill_price(String.valueOf(price));
					list.get(i).setBill_product_number(String.valueOf(number));
					list.remove(j);
					i=0;
					j=1;
				}
			}
		}
		
		return list;
	}
	
}
